//
//  RTNavigationController.m
//  WeiboSina
//
//  Created by Brisinga on 16/3/4.
//  Copyright © 2016年 Root. All rights reserved.
//

#import "RTNavigationController.h"

@interface RTNavigationController ()

@end

@implementation RTNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}


#pragma mark - 重写push方法
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {

    if (self.childViewControllers.count) {
        
        NSString *title = @"返回";
        
        if (self.childViewControllers.count==1) {
            
            title = self.childViewControllers.firstObject.title;
        }
        
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem buttonItemWithImageName:nil title:title addTarget:self action:@selector(popAction)];
    }
    
    [super pushViewController:viewController animated:YES];
}



#pragma mark - 返回上一个界面
- (void)popAction {
    
    [self popViewControllerAnimated:YES];
}


@end
